package com.lora.enums;

import com.google.common.collect.Maps;
import lombok.Getter;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Getter
public enum EquipmentEnum {

    WIRELESS_SMOKE_FEEL("1", "无线烟感"),
    TEMPERATURE_HUMIDITY("2", "温湿度"),
    INFRARED_INDUCTION("3", "红外感应器"),
    GATE_MAGNETISM("4","状态磁感器"),
    HUMAN_ACTIVE_INFRARED("5","人体活动探测器"),
    FRESH_AIR_CONTOL_AIR_CONDITIONING("6","新风控制器_空调"),
    ELECTRICITY_METER("7","三相电量仪"),
    SWITCHING_VALUE("8","开关量"),
    UPS("9","UPS数据采集"),
    AIR_CONDITIONING_UPS("10","空调数据采集"),
    FRESH_AIR_UPS("11","新风系统数据采集"),
    ACCSS_CONTROL("12","门禁"),
    CAMERA("13","摄像头"),
    SERVICE("14","服务器地址");

    private String value;
    private String title;

    EquipmentEnum(String value, String title) {
        this.value = value;
        this.title = title;
    }

    Map<String, String> getMap(EquipmentEnum equipment) {
        Map<String, String> equipmentMap = Maps.newHashMap();
        equipmentMap.put(equipment.getValue(), equipment.getTitle());
        return equipmentMap;
    }

    public static EquipmentEnum getEquipmentByType(String type) {
        return Arrays.stream(EquipmentEnum.values()).filter(v -> v.getValue().equals(type)).findAny().orElse(null);
    }

    public static List<Map<String, String>> getEquipments() {
        return Arrays.stream(EquipmentEnum.values()).map(v -> v.getMap(v)).collect(Collectors.toList());
    }

}
